package com.aj.http.response;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.aj.databases.entry.PhotoInfo;

public class AlbumPhotoQueryResponse extends BaseRespond {
	private List<PhotoInfo> dataList;

	public AlbumPhotoQueryResponse(JSONObject json) {
		super(json);
		try {
			if (common.getResult() != null) {
				if (!common.getResult().isNull("photoList")) {
					dataList = new ArrayList<PhotoInfo>();
					JSONArray jsonArray = common.getResult().getJSONArray(
							"photoList");
					PhotoInfo personPhotoInfo;
					for (int i = 0; i < jsonArray.length(); i++) {
						JSONObject tempJsonObject = jsonArray.getJSONObject(i);
						personPhotoInfo = new PhotoInfo();
						personPhotoInfo.setIsPrivate(tempJsonObject
								.getString("isPrivate"));
						personPhotoInfo.setPhotoId(tempJsonObject
								.getString("photoId"));
						personPhotoInfo.setPhoto(tempJsonObject
								.getString("photoUrl"));
						dataList.add(personPhotoInfo);
					}
				}
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}
	}

	public List<PhotoInfo> getDataList() {
		return dataList;
	}

	public void setDataList(List<PhotoInfo> dataList) {
		this.dataList = dataList;
	}

}
